//
// Created by xili on 2024/8/4 10:14.
// Go big or go home.
//

#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    int minimumOperationsToMakeKPeriodic(string word, int k) {
        //用哈希表统计每k个字串的出现次数
        //看出现次数最多的字串
        unordered_map<string, int> ump;
        int n = word.size();
        for (int i = k; i <= n; i += k) {
            ump[word.substr(i-k, k)]++;
        }
        int sum = 0;
        int times;
        for (auto &item: ump) {
            sum += item.second;
            times = max(times, item.second);
        }
        return sum - times;
    }
};